package cn.com.dhcc.app.pub.core.util.dateformatter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateFormatter {
	public static String getToday(String format) {
		Date today = new Date();
		SimpleDateFormat ft = new SimpleDateFormat(format); 
		String date = ft.format(today);
		return date;
	}
	
	public static Date getTodayForDate(String format) {
		Date today = new Date();
		SimpleDateFormat ft = new SimpleDateFormat(format);
		String t = ft.format(today);
		try {
			today = ft.parse(t);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return today;
	}
	
	public static String getDateBasedOnToday(String format, int shift) {
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DATE, shift);
		String date = new SimpleDateFormat(format).format(calendar.getTime());
		return date;
	}
	
	public static Date getDateBasedOnTodayForDate(String format, int shift) {
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DATE, shift);
		return calendar.getTime();
	}
}
